package se.lth.student.axisandroidcam.server;

import java.io.IOException;

import se.lth.student.axisandroidcam.client.Toolbox;

public class Server {

	public static final long IDLE_PERIOD = 5000;
	public static final long MOVIE_PERIOD = 250;
	public static final int PORT = 31415;
	public static int CAMERA_ID = 2;
	
	
	
	public static void main(String[] args){		
		//CAMERA_ID = Integer.parseInt(args[0]);
		CameraThread cameraThread = new CameraThread();
		cameraThread.start();
		ServerOut networkOut = new ServerOut(cameraThread);
		ServerIn networkIn = new ServerIn(networkOut);
		
		JPEGHTTPServer theServer = new JPEGHTTPServer(6077+ CAMERA_ID, cameraThread);
	    theServer.start();

		
		boolean isConnected;
		do{
			isConnected = networkOut.connect();
		}while(!isConnected);
		Toolbox.printDebug("Server Connected");
		do{
			isConnected = networkIn.connect();
		}while(!isConnected);
		Toolbox.printDebug("Server-In Connected");
		
		networkOut.start();
		networkIn.start();
		
	}
}
